package com.easywan.vo;

import java.awt.image.BufferedImage;
import java.io.IOException;

import com.easywan.util.ApiUtils;
import com.easywan.util.ImageUtils;

public class Hearthstone {
	/**
	 * 卡牌类型
	 */
	Integer carType;
	
	/**
	 * 根据卡牌<b>职业</b> 返回卡牌主框架地址
	 * @param prefisson 职业
	 * 		1.中立
	 * 		2.法师
	 * 		3.术士
	 * 		4.战士
	 * 		5.德鲁伊
	 * 		6.牧师
	 * 		7.潜行者
	 * 		8.猎人
	 * 		9.圣骑士
	 * 		10.武僧
	 * 		11.死亡其实
	 * 		12.萨满
	 * @return
	 * @throws 卡牌类型不存在 | 职业不存在
	 */
	public String getCarFrame(int prefision){
		String prefisionString  = "";
		switch(prefision){
		case 1:
			prefisionString = "zhong";
			break;
		case 2:
			prefisionString = "fa";
			break;
		case 3:
			prefisionString = "shu";
			break;
		case 4:
			prefisionString = "zhan";
			break;
		case 5:
			prefisionString = "de";
			break;
		case 6:
			prefisionString = "mu";
			break;
		case 7:
			prefisionString = "qian";
			break;
		case 8:
			prefisionString = "lie";
			break;
		case 9:
			prefisionString = "shen";
			break;
		case 10:
			prefisionString = "wu";
			break;
		case 11:
			prefisionString = "si";
			break;
		case 12:
			prefisionString = "sa";
			break;
		default:
				throw new RuntimeException("职业不存在");
		}
		return getCarTypeString() + "/" + prefisionString+".png";
	}
	/**
	 * 获取种族路径
	 * @return
	 */
	public String getRace(){
		return getCarTypeString() + "/zhongzu.png";
	}
	/**
	 * 根据卡牌类型返回路径
	 * http://www.diaiy.com/frontend/web/app/lushi/suicong/baika.png
	 * @param CarType 卡牌类型
	 * 	1.普通卡
	 * 	2.白卡
	 * 	3.蓝卡
	 * 	4.紫卡
	 * 	5.传说
	 * @return
	 * @throws 卡牌类型不存在
	 */
	public String getCarType(int CarType){
		String carTypeString  = getCarTypeString();
		switch(CarType){
		case 1:
			return carTypeString + "/zhong.png";
		case 2:
			return carTypeString + "/baika.png";
		case 3:
			return carTypeString + "/lanka.png";
		case 4:
			return carTypeString + "/zika.png";
		case 5:
			return carTypeString + "/chengka.png";
		}
		throw new RuntimeException("卡牌类型不存在");
	}
	/**
	 * 获取索要消耗法力的路径
	 * http://www.diaiy.com/frontend/web/app/lushi/suicong/shuxing/fali_1.png
	 * @param value 法力值
	 * @return 
	 */
	public String getMagic(Integer value){
		return getCarTypeString()+"/shuxing/fali_"+value+".png";
	}
	/**
	 * 获取攻击力的路径
	 * http://www.diaiy.com/frontend/web/app/lushi/suicong/shuxing/gongji_1.png
	 * http://www.diaiy.com/frontend/web/app/lushi/wuqi/shuxing/gongji_1.png
	 * @param value 攻击值
	 * @return
	 */
	public String getHit(Integer value){
		return getCarTypeString()+"/shuxing/gongji_"+value+".png";
	}
	/**
	 * http://www.diaiy.com/frontend/web/app/lushi/suicong/shuxing/shengming_0.png
	 * http://www.diaiy.com/frontend/web/app/lushi/wuqi/shuxing/shengming_0.png
	 * @param value 生命值
	 * @return
	 */
	public String getHealth(Integer value){
		return getCarTypeString()+"/shuxing/shengming_"+value+".png";
	}
	
	public String getCarTypeString(){
		switch(carType){
		case 1:
			return "suicong";
		case 2:
			return "fashu";
		case 3:
			return "wuqi";
		}
		throw new RuntimeException("卡牌类型不存在");
	}
	/**
	 * 创建图片，返回图片
	 * @param carType
	 * @param carFramePath
	 * @param magicPath
	 * @param pictureUrl
	 * @param carTypePath
	 * @param waterMark
	 * @param hitPath
	 * @param healthPath
	 * @return
	 */
	public BufferedImage creater(Integer carType,
			String carFramePath,String magicPath,
			String pictureUrl,
			String carTypePath,String waterMark,
			String hitPath,String healthPath,
			String race,
			String name){
		this.carType = carType;
		try {
			//获取住框架
			BufferedImage bi = ImageUtils.getImage(carFramePath,ApiUtils.getHearthstoneImageApi(carFramePath));
			//添加法力值
			ImageUtils.addImage(bi, ImageUtils.getImage(magicPath,ApiUtils.getHearthstoneImageApi(magicPath)));
			//添加插画
			//添加名字
			//添加卡牌稀有度
			ImageUtils.addImage(bi, ImageUtils.getImage(carTypePath,ApiUtils.getHearthstoneImageApi(carTypePath)));
			//添加水印
			ImageUtils.addImage(bi, ImageUtils.getImage(waterMark,ApiUtils.getHearthstoneImageApi(waterMark)),230,460);
			//添加攻击力
			ImageUtils.addImage(bi, ImageUtils.getImage(hitPath,ApiUtils.getHearthstoneImageApi(hitPath)));
			//添加生命力
			ImageUtils.addImage(bi, ImageUtils.getImage(healthPath,ApiUtils.getHearthstoneImageApi(healthPath)));
			//添加描述
			//添加种族
			ImageUtils.addImage(bi, ImageUtils.getImage(race,ApiUtils.getHearthstoneImageApi(race)));
			return bi;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void setCarType(Integer i) {
		// TODO Auto-generated method stub
		this.carType = i;
	}
	public Integer getCarType() {
		// TODO Auto-generated method stub
		return carType;
	}
	
	
	
}
